package com.bifrost.entity;

import javax.persistence.*;
import java.io.Serializable;


/**
 * The persistent class for the MERCHANT_ATTRIBUTE database table.
 */
@Entity
@Table(name = "ORDER_ATTRIBUTE",indexes = {
        @Index(name = "ORDER_ID_NAME_INDEX",columnList = "ORDER_ID,ATTRIBUTE_NAME",unique = true)
        ,@Index(name = "NAME_ORDER_ID_INDEX",columnList = "ATTRIBUTE_NAME,ORDER_ID",unique = true)
})
@NamedQuery(name = "OrderAttribute.findAll", query = "SELECT m FROM OrderAttribute m")
public class OrderAttribute implements Serializable {
    private static final long serialVersionUID = 1L;
    public static final String LOYALTY_NUMBER="LOYALTYNO";
    /**
     * 外部系统积分状态
     */
    public static final String CRM_STATUS ="CRM_STATUS";
    /**
     * 积分成功
     */
    public static final String SUCCESS="SUCCESS";
    /**
     * 积分失败
     */
    public static final String FAILURE="FAILURE";
    /**
     * 已全部退还积分
     */
    public static final String ROLLBACK_ALL="ROLLBACK_ALL";
    /**
     * 已部分退还积分
     */
    public static final String ROLLBACK_PARTIAL="ROLLBACK_PARTIAL";
    /**
     * 退还失败
     */
    public static final String ROLLBACK_FAILURE="ROLLBACK_FAILURE";

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ORDER_ATTRIBUTE_ID", unique = true, nullable = false)
    private Long orderAttributeId;

    @Column(name = "ATTRIBUTE_NAME", nullable = false, length = 32)
    private String attributeName;

    @Column(name = "ATTRIBUTE_VALUE", length = 255)
    private String attributeValue;

    //bi-directional many-to-one association to MerchantStore
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ORDER_ID", nullable = false ,foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Order order;

    public OrderAttribute() {
    }

    public OrderAttribute(String attributeName, String attributeValue, Order order) {
        this.attributeName = attributeName;
        this.attributeValue = attributeValue;
        this.order = order;
    }

    public Long getOrderAttributeId() {
        return orderAttributeId;
    }

    public void setOrderAttributeId(Long orderAttributeId) {
        this.orderAttributeId = orderAttributeId;
    }

    public String getAttributeName() {
        return this.attributeName;
    }

    public void setAttributeName(String attributeName) {
        this.attributeName = attributeName;
    }

    public String getAttributeValue() {
        return this.attributeValue;
    }

    public void setAttributeValue(String attributeValue) {
        this.attributeValue = attributeValue;
    }

    public Order getOrder() {
        return order;
    }

    public void setOrder(Order order) {
        this.order = order;
    }
}